#include <iostream>
#include <algorithm>
using namespace std;

static int sum = 0;

int check(int i)
{
	int ret = 0;
	while (i)
	{
		if (i % 10 == 2)
			ret++;

		i /= 10;
	}

	return ret;
}

int main()
{
	for (int i = 1; i <= 2020; i++)
	{
		sum += check(i);
	}

	cout << sum << endl;
	return 0;
}
